package com.czd.support.service;

import com.czd.base.model.Paginate;
import com.czd.base.service.BaseService;
import com.czd.support.common.Configuration;
import com.czd.support.model.Phrasebook;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Jerry.hu
 * Create: Jerry.hu (2014-11-22 15:22)
 * Description:
 * To change this template use File | Settings | File Templates.
 */
@Service
public class PhrasebookService extends BaseService<Phrasebook> {

    public boolean insertPhrasebook(Phrasebook phrasebook){
        return this.insert(sqlId("insert"),phrasebook);
    }

    public boolean updatePhrasebook(Phrasebook phrasebook){
        return this.update(sqlId("update"),phrasebook);
    }

    public List<Phrasebook> getPhrasebooks(String typeCode){
        return this.selectList(sqlId("queryPhrasebooks"),typeCode);
    }

    public Paginate queryForPaginate(Phrasebook phrasebook){
        phrasebook.setPageSize(Configuration.getInstance().getDefault_page_size());
        return this.queryForPaginate(sqlId("queryForPaginate"),sqlId("phrasebookCount"),phrasebook);
    }

    public Phrasebook findById(int id) {
        return  this.selectOne(sqlId("findById"),id);
    }

    public boolean checkContent(Phrasebook phrasebook) {
        return this.count(sqlId("checkContent"),phrasebook) > 0;
    }
}
